<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TTMath: ttmath::CGamma&lt; ValueType &gt; Struct Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="ttmath_logo_for_doxygen_doc.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">TTMath
   &#160;<span id="projectnumber">0.9.4_prerelease_2019-07-31</span>
   </div>
   <div id="projectbrief">&nbsp;C++ bignum library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacettmath.html">ttmath</a></li><li class="navelem"><a class="el" href="structttmath_1_1_c_gamma.html">CGamma</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Data Fields</a>  </div>
  <div class="headertitle">
<div class="title">ttmath::CGamma&lt; ValueType &gt; Struct Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>&gt;</code></p>
<div class="dynheader">
Collaboration diagram for ttmath::CGamma&lt; ValueType &gt;:</div>
<div class="dyncontent">
<div class="center"><img src="structttmath_1_1_c_gamma__coll__graph.png" border="0" usemap="#ttmath_1_1_c_gamma_3_01_value_type_01_4_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a0741221115113a71d3c9b183a46042d6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structttmath_1_1_c_gamma.html#a0741221115113a71d3c9b183a46042d6">InitAll</a> ()</td></tr>
<tr class="separator:a0741221115113a71d3c9b183a46042d6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Data Fields</h2></td></tr>
<tr class="memitem:abb96b3bc0addd45bb851081908f6f865"><td class="memItemLeft" align="right" valign="top">std::vector&lt; ValueType &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structttmath_1_1_c_gamma.html#abb96b3bc0addd45bb851081908f6f865">fact</a></td></tr>
<tr class="separator:abb96b3bc0addd45bb851081908f6f865"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a672ed255c427f3077dea7a2e2ea0967d"><td class="memItemLeft" align="right" valign="top">std::vector&lt; ValueType &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structttmath_1_1_c_gamma.html#a672ed255c427f3077dea7a2e2ea0967d">bern</a></td></tr>
<tr class="separator:a672ed255c427f3077dea7a2e2ea0967d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a32625db73df913efb0603f0e50d3855f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classttmath_1_1_history.html">History</a>&lt; ValueType &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structttmath_1_1_c_gamma.html#a32625db73df913efb0603f0e50d3855f">history</a></td></tr>
<tr class="separator:a32625db73df913efb0603f0e50d3855f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;class ValueType&gt;<br />
struct ttmath::CGamma&lt; ValueType &gt;</h3>

<p>this is an auxiliary class used when calculating <a class="el" href="namespacettmath.html#aaf1312e301f4800c67164f4eb8a5e017">Gamma()</a> or <a class="el" href="namespacettmath.html#ae0a248c8618c9ac4e3edf6095fe31f92">Factorial()</a></p>
<p>in multithreaded environment you can provide an object of this class to the <a class="el" href="namespacettmath.html#aaf1312e301f4800c67164f4eb8a5e017">Gamma()</a> or <a class="el" href="namespacettmath.html#ae0a248c8618c9ac4e3edf6095fe31f92">Factorial()</a> function, e.g; </p><pre class="fragment">typedef Big&lt;1, 3&gt; MyBig;
MyBig x = 123456;
CGamma&lt;MyBig&gt; cgamma;
std::cout &lt;&lt; Gamma(x, cgamma);
</pre><p>each thread should have its own CGamma&lt;&gt; object</p>
<p>in a single-thread environment a CGamma&lt;&gt; object is a static variable and you don't have to explicitly use it, e.g. </p><pre class="fragment">typedef Big&lt;1, 3&gt; MyBig;
MyBig x = 123456;
std::cout &lt;&lt; Gamma(x);
</pre> 
<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00742">742</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="a0741221115113a71d3c9b183a46042d6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0741221115113a71d3c9b183a46042d6">&#9670;&nbsp;</a></span>InitAll()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ValueType &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="structttmath_1_1_c_gamma.html">ttmath::CGamma</a>&lt; ValueType &gt;::InitAll </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>this method prepares some coefficients: factorials and Bernoulli numbers stored in 'fact' and 'bern' objects</p>
<p>how many values should be depends on the size of the mantissa - if the mantissa is larger then we must calculate more values for a mantissa which consists of 256 bits (8 words on a 32bit platform) we have to calculate about 30 values (the size of fact and bern will be 30), and for a 2048 bits mantissa we have to calculate 306 coefficients</p>
<p>you don't have to call this method, these coefficients will be automatically calculated when they are needed</p>
<p>you must note that calculating these coefficients is a little time-consuming operation, (especially when the mantissa is large) and first call to <a class="el" href="namespacettmath.html#aaf1312e301f4800c67164f4eb8a5e017">Gamma()</a> or <a class="el" href="namespacettmath.html#ae0a248c8618c9ac4e3edf6095fe31f92">Factorial()</a> can take more time than next calls, and in the end this is the point when <a class="el" href="structttmath_1_1_c_gamma.html#a0741221115113a71d3c9b183a46042d6">InitAll()</a> comes in handy: you can call this method somewhere at the beginning of your program</p>
<p>this method prepares some coefficients: factorials and Bernoulli numbers stored in 'fact' and 'bern' objects</p>
<p>we're defining the method here because we're using <a class="el" href="namespacettmath.html#aaf1312e301f4800c67164f4eb8a5e017">Gamma()</a> function which is not available in <a class="el" href="ttmathobjects_8h.html" title="Mathematic functions.">ttmathobjects.h</a></p>
<p>read the doc info in <a class="el" href="ttmathobjects_8h.html" title="Mathematic functions.">ttmathobjects.h</a> file where CGamma&lt;&gt; struct is declared </p>

<p class="definition">Definition at line <a class="el" href="ttmath_8h_source.html#l02840">2840</a> of file <a class="el" href="ttmath_8h_source.html">ttmath.h</a>.</p>
<div class="fragment"><div class="line"><a name="l02841"></a><span class="lineno"> 2841</span>&#160;    {</div><div class="line"><a name="l02842"></a><span class="lineno"> 2842</span>&#160;        ValueType x = <a class="code" href="ttmathtypes_8h.html#a778d79adcd3e74d5e26708e7cbdcf244">TTMATH_GAMMA_BOUNDARY</a> + 1;</div><div class="line"><a name="l02843"></a><span class="lineno"> 2843</span>&#160;        </div><div class="line"><a name="l02844"></a><span class="lineno"> 2844</span>&#160;        <span class="comment">// history.Remove(x) removes only one object</span></div><div class="line"><a name="l02845"></a><span class="lineno"> 2845</span>&#160;        <span class="comment">// we must be sure that there are not others objects with the key &#39;x&#39;</span></div><div class="line"><a name="l02846"></a><span class="lineno"> 2846</span>&#160;        <span class="keywordflow">while</span>( <a class="code" href="structttmath_1_1_c_gamma.html#a32625db73df913efb0603f0e50d3855f">history</a>.Remove(x) )</div><div class="line"><a name="l02847"></a><span class="lineno"> 2847</span>&#160;        {</div><div class="line"><a name="l02848"></a><span class="lineno"> 2848</span>&#160;        }</div><div class="line"><a name="l02849"></a><span class="lineno"> 2849</span>&#160;</div><div class="line"><a name="l02850"></a><span class="lineno"> 2850</span>&#160;        <span class="comment">// the simplest way to initialize is to call the Gamma function with (TTMATH_GAMMA_BOUNDARY + 1)</span></div><div class="line"><a name="l02851"></a><span class="lineno"> 2851</span>&#160;        <span class="comment">// when x is larger then fewer coefficients we need</span></div><div class="line"><a name="l02852"></a><span class="lineno"> 2852</span>&#160;        <a class="code" href="namespacettmath.html#aaf1312e301f4800c67164f4eb8a5e017">Gamma</a>(x, *<span class="keyword">this</span>);</div><div class="line"><a name="l02853"></a><span class="lineno"> 2853</span>&#160;    }</div><div class="ttc" id="structttmath_1_1_c_gamma_html_a32625db73df913efb0603f0e50d3855f"><div class="ttname"><a href="structttmath_1_1_c_gamma.html#a32625db73df913efb0603f0e50d3855f">ttmath::CGamma::history</a></div><div class="ttdeci">History&lt; ValueType &gt; history</div><div class="ttdef"><b>Definition:</b> <a href="ttmathobjects_8h_source.html#l00782">ttmathobjects.h:782</a></div></div>
<div class="ttc" id="namespacettmath_html_aaf1312e301f4800c67164f4eb8a5e017"><div class="ttname"><a href="namespacettmath.html#aaf1312e301f4800c67164f4eb8a5e017">ttmath::Gamma</a></div><div class="ttdeci">ValueType Gamma(const ValueType &amp;n, CGamma&lt; ValueType &gt; &amp;cgamma, ErrorCode *err=0, const volatile StopCalculating *stop=0)</div><div class="ttdef"><b>Definition:</b> <a href="ttmath_8h_source.html#l02679">ttmath.h:2679</a></div></div>
<div class="ttc" id="ttmathtypes_8h_html_a778d79adcd3e74d5e26708e7cbdcf244"><div class="ttname"><a href="ttmathtypes_8h.html#a778d79adcd3e74d5e26708e7cbdcf244">TTMATH_GAMMA_BOUNDARY</a></div><div class="ttdeci">#define TTMATH_GAMMA_BOUNDARY</div><div class="ttdef"><b>Definition:</b> <a href="ttmathtypes_8h_source.html#l00338">ttmathtypes.h:338</a></div></div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="ttmath_8h_source.html#l02679">ttmath::Gamma()</a>, and <a class="el" href="ttmathtypes_8h_source.html#l00338">TTMATH_GAMMA_BOUNDARY</a>.</p>

</div>
</div>
<h2 class="groupheader">Field Documentation</h2>
<a id="a672ed255c427f3077dea7a2e2ea0967d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a672ed255c427f3077dea7a2e2ea0967d">&#9670;&nbsp;</a></span>bern</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ValueType&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">std::vector&lt;ValueType&gt; <a class="el" href="structttmath_1_1_c_gamma.html">ttmath::CGamma</a>&lt; ValueType &gt;::bern</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>this table holds Bernoulli numbers 1 -0.5 0.166666666666666666666666667 0 -0.0333333333333333333333333333 0 0.0238095238095238095238095238 0 -0.0333333333333333333333333333 0 0.075757575757575757575757576 ..... </p>

<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00773">773</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>

</div>
</div>
<a id="abb96b3bc0addd45bb851081908f6f865"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abb96b3bc0addd45bb851081908f6f865">&#9670;&nbsp;</a></span>fact</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ValueType&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">std::vector&lt;ValueType&gt; <a class="el" href="structttmath_1_1_c_gamma.html">ttmath::CGamma</a>&lt; ValueType &gt;::fact</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>this table holds factorials 1 1 2 6 24 120 720 ....... </p>

<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00755">755</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>

</div>
</div>
<a id="a32625db73df913efb0603f0e50d3855f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a32625db73df913efb0603f0e50d3855f">&#9670;&nbsp;</a></span>history</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ValueType&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classttmath_1_1_history.html">History</a>&lt;ValueType&gt; <a class="el" href="structttmath_1_1_c_gamma.html">ttmath::CGamma</a>&lt; ValueType &gt;::history</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>here we store some calculated values (this is for speeding up, if the next argument of <a class="el" href="namespacettmath.html#aaf1312e301f4800c67164f4eb8a5e017">Gamma()</a> or <a class="el" href="namespacettmath.html#ae0a248c8618c9ac4e3edf6095fe31f92">Factorial()</a> is in the 'history' then the result we are not calculating but simply return from the 'history' object) </p>

<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00782">782</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>

<p class="reference">Referenced by <a class="el" href="ttmath_8h_source.html#l02679">ttmath::Gamma()</a>.</p>

</div>
</div>
<hr/>The documentation for this struct was generated from the following files:<ul>
<li><a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a></li>
<li><a class="el" href="ttmath_8h_source.html">ttmath.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
